package com.woniuxy.store.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.store.infra.mapper.FunctionMapper;
import com.woniuxy.store.infra.model.Function;
import com.woniuxy.store.service.FunctionService;
import exception.MallException;
import org.springframework.stereotype.Service;
import result.CommonResultCodeEnum;

import java.math.BigDecimal;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zz
 * @since 2023-07-20
 */
@Service
public class FunctionServiceImpl extends ServiceImpl<FunctionMapper, Function> implements FunctionService {



    @Override
    public void addFunction(String functionName) {

        QueryWrapper<Function> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("function_name",functionName);
        Function one = getOne(queryWrapper);
        if (one!=null){
            throw new MallException("该功能已存在", CommonResultCodeEnum.INVALID_PARAM);
        }
        Function function = new Function();
        function.setFunctionName(functionName);
        save(function);

    }
}
